home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / rkpls301.zip / RKPDEMO.ZIP / GENKEY.PAS < prev    next >
Pascal/Delphi Source File  |  1993-03-04  |  3KB  |  105 lines

  1. Program GenKey;
  2.  
  3. {
  4.  This is a sample programme using RkPlus.  It is a sample of a registration
  5.  key generation programme that would be used by the programmer to create
  6.  registration keys to be distributed to registered users.  The user would
  7.  then enter the registration key into a registration programme (such as
  8.  Register or Brand) to create the key file. The key generation programme
  9.  itself would NOT be distributed, as it would allow users to generate keys.
  10.  This sample can create a 1 or 2 month limited use demo key, a 1 year
  11.  registration key or an unlimited registration key, for the Sample1, Sample2,
  12.  Sample3 and Sample4 programmes.
  13.  
  14.  GenKey uses the example encoding unit Encode.
  15. }
  16.  
  17.  
  18. Uses
  19.   Crt,
  20.   Dos,
  21.   RkPlus,
  22.   Encode;
  23.  
  24.  
  25. Const
  26.   MonthNames : Array[1..12] of String[3]
  27.   = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  28.  
  29.  
  30. Var
  31.   kc          : Char;
  32.   ey,em,dd,dw : Word;
  33.  
  34.  
  35. Begin
  36.   SetProgID('Sample');
  37.   SetKeyFile('Sample');
  38.   WriteLn('GenKey');
  39.   WriteLn('Registration Key Generation Programme for Sample1/Sample2/Sample3/Sample4');
  40.   WriteLn('See RKPLUS.DOC for more info');
  41.   WriteLn;
  42.   WriteLn('GenKey would be used by the programmer to create registration keys.');
  43.   WriteLn('It would NOT be distributed.');
  44.   WriteLn;
  45.   Write('Enter name of person to register : ');
  46.   ReadLn(Rkp.Name1);
  47.   WriteLn;
  48.   WriteLn('[1] 1 month limited use demo key');
  49.   WriteLn('[2] 2 month limited use demo key');
  50.   WriteLn('[R] registration key (1 year)');
  51.   WriteLn('[U] unlimited registration key');
  52.   WriteLn;
  53.   Write('Type? ');
  54.   kc := UpCase(ReadKey);
  55.   WriteLn(kc);
  56.   WriteLn;
  57.   GetDate(ey,em,dd,dw);
  58.   If (kc = '1') then Begin
  59.     If (em = 12) then Begin
  60.       em := 1;
  61.       Inc(ey);
  62.     End Else
  63.       Inc(em);
  64.     WriteLn('Creating limited use demo key (will expire 1-',MonthNames[em],'-',ey,')');
  65.     Rkp.Level := 0;
  66.     Rkp.ExpYear := ey;
  67.     Rkp.ExpMonth := em;
  68.   End Else If (kc = '2') then Begin
  69.     If (em = 11) then Begin
  70.       em := 1;
  71.       Inc(ey);
  72.     End Else If (em = 12) then Begin
  73.       em := 2;
  74.       Inc(ey);
  75.     End Else Begin
  76.       Inc(em,2);
  77.     End;
  78.     WriteLn('Creating limited use demo key (will expire 1-',MonthNames[em],'-',ey,')');
  79.     Rkp.Level := 0;
  80.     Rkp.ExpYear := ey;
  81.     Rkp.ExpMonth := em;
  82.   End Else If (kc in ['R','r']) then Begin
  83.     If (em = 12) then Begin
  84.       em := 1;
  85.       Inc(ey);
  86.     End Else
  87.       Inc(em);
  88.     Inc(ey);
  89.     WriteLn('Creating registration key (will expire 1-',MonthNames[em],'-',ey,')');
  90.     Rkp.Level := 1;
  91.     Rkp.ExpYear := ey;
  92.     Rkp.ExpMonth := em;
  93.   End Else Begin
  94.     WriteLn('Creating unlimited registration key');
  95.     Rkp.Level := 1;
  96.     Rkp.ExpYear := 0;
  97.     Rkp.ExpMonth := 0;
  98.   End;
  99.   Rkp.Name2 := '';
  100.   Rkp.Name3 := '';
  101.   CreateKey;
  102.   WriteLn;
  103.   WriteLn('Key is ',Rkp.Key);
  104. End.
  105.